﻿#include "pch.h"
#include <iostream> 
#include <sstream>  
namespace WZGLPDQ {

	//模板函数：将string类型变量转换为常用的数值类型（此方法具有普遍适用性） 
	template <class Type>
	Type stringToNum(const std::string& str) {
		std::istringstream iss(str);
		Type num;
		iss >> num;
		return num;
	}

	TEST(WZGLPDQ, s2n) {
		std::string str("00801");
		std::cout << stringToNum<int>(str) << std::endl;
		std::string str1("false");
		std::cout << stringToNum<bool>(str1) << std::endl;
		std::string str2("1");
		std::cout << stringToNum<bool>(str2) << std::endl;
		std::string str3("0");
		std::cout << stringToNum<bool>(str3) << std::endl;
		std::string str4("1.10");
		std::cout << stringToNum<double>(str4) << std::endl;
	}



}
